import React from 'react'
import { useLocation } from 'react-router-dom'
import { Button, Modal } from 'antd'
const hideModalData = sessionStorage.getItem('hideModal') ? JSON.parse(sessionStorage.getItem('hideModal')!) : {}
const NotifyModal = ({ visible, list, onCancel }: any) => {
  const { pathname } = useLocation()

  const isHideModal = hideModalData[pathname]
  if (isHideModal) return null
  return (
    <Modal title="涉案财物管理系统使用提示" footer={null} visible={visible} onCancel={onCancel}>
      <div>【请注意】</div>
      {list &&
        list.length &&
        list.map((item: any, index: number) => {
          return (
            <p key={index}>
              {index + 1}.{item}
            </p>
          )
        })}
      <footer style={{ display: 'flex', justifyContent: 'center' }}>
        <Button
          onClick={() => {
            hideModalData[pathname] = true
            sessionStorage.setItem('hideModal', JSON.stringify(hideModalData))
            onCancel()
          }}
          type="primary"
          danger
        >
          不再提醒
        </Button>
        <Button onClick={onCancel} style={{ marginLeft: 8 }} type="primary">
          确定
        </Button>
      </footer>
    </Modal>
  )
}

export default NotifyModal
